<template>
  <footer class="footer">
    <span class="todo-count">剩余：<strong>{{isTotal}}</strong></span>
    <ul class="filters">
      <li>
        <a :class="{selected:show === 'all'}" href="javascript:;" @click="isShow('all')">全部</a>
      </li>
      <li>
        <a :class="{selected:show === 'no'}" href="javascript:;" @click="isShow('no')">未完成</a>
      </li>
      <li>
        <a :class="{selected:show === 'yes'}" href="javascript:;" @click="isShow('yes')">已完成</a>
      </li>
    </ul>
    <button class="clear-completed" @click="clearIsDone">清除已完成</button>
  </footer>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
    methods: {
      isShow(str){
        this.$store.commit('todofooter/isShow',str)
      },
      clearIsDone() {
        console.log(1);
        this.$store.commit('todomain/clearIsDone')
      }
    },
    computed: {
      ...mapGetters(['list']),
      show() {
        return this.$store.state.todofooter.show
      },
      isTotal() {
        return this.list.length
      }
    }
}
</script>
